home *** CD-ROM | disk | FTP | other *** search
/ NeXT Education Software Sampler 1992 Fall / NeXT Education Software Sampler 1992 Fall.iso / Mathematics / Notebooks / SigProc2.0 / Packages / SignalProcessing / Support / MDSupport.m < prev    next >
Encoding:
Text File  |  1992-08-18  |  6.7 KB  |  205 lines

  1. (*  :Title:    Supplemental Platform for Transforms  *)
  2.  
  3. (*  :Authors:    Brian Evans, James McClellan  *)
  4.  
  5. (*
  6.     :Summary:    Plots of m-D magnitude/phase responses
  7.         Generates of m-D pole-zero diagrams and root loci
  8.  *)
  9.  
  10. (*  :Context:    SignalProcessing`Support`TransSupport`  *)
  11.  
  12. (*  :PackageVersion:  2.7    *)
  13.  
  14. (*
  15.     :Copyright:    Copyright 1989-1991 by Brian L. Evans
  16.         Georgia Tech Research Corporation
  17.  
  18.     Permission to use, copy, modify, and distribute this software
  19.     and its documentation for any purpose and without fee is
  20.     hereby granted, provided that the above copyright notice
  21.     appear in all copies and that both that copyright notice and
  22.     this permission notice appear in supporting documentation,
  23.     and that the name of the Georgia Tech Research Corporation,
  24.     Georgia Tech, or Georgia Institute of Technology not be used
  25.     in advertising or publicity pertaining to distribution of the
  26.     software without specific, written prior permission.  Georgia
  27.     Tech makes no representations about the suitability of this
  28.     software for any purpose.  It is provided "as is" without
  29.     express or implied warranty.
  30.  *)
  31.  
  32. (*  :History:    *)
  33.  
  34. (*  :Keywords:    pole-zero diagrams, frequency response  *)
  35.  
  36. (*
  37.     :Source:    {Multidimensional Digital Signal Processing}, 1984,
  38.           by D. Dudgeon and R. Mersereau
  39.  *)
  40.  
  41. (*
  42.     :Warning:    The transform objects LTransData and ZTransData must
  43.         be defined before this file is loaded (see "ROC.m").
  44.  *)
  45.  
  46. (*  :Mathematica Version:  1.2 or 2.0  *)
  47.  
  48. (*  :Limitation:  *)
  49.  
  50. (*
  51.     :Discussion:  This file has two sections:
  52.  
  53.         A.  Magnitude and phase plots (for 2-D signals)
  54.         B.  Pole-zero diagrams and root maps (for 2-D transforms)
  55.  
  56.     These sections display the results of transform objects.
  57.  *)
  58.  
  59. (*  :Functions:      *)
  60.  
  61.  
  62. If [ TrueQ[ $VersionNumber >= 2.0 ],
  63.      Off[ General::spell ];
  64.      Off[ General::spell1 ] ]
  65.  
  66.  
  67. (*  B E G I N     P A C K A G E  *)
  68.  
  69. BeginPackage[ "SignalProcessing`Support`MDSupport`" ]
  70. EndPackage[]
  71.  
  72. BeginPackage[ "SignalProcessing`Support`TransSupport`",
  73.           "SignalProcessing`Support`ROC`",
  74.           "SignalProcessing`Support`SigProc`",
  75.           "SignalProcessing`Support`SupCode`" ]
  76.  
  77.  
  78. Begin["`Private`"]
  79.  
  80.  
  81. (*  lineImpulsemDT  *)
  82. lineImpulsemDT[transq_, t_, s_, slist_, nleft_, fun_] :=
  83.     Block [    {dim, dimsleft, lastrminus, lastrplus, result, rminus, rplus},
  84.         rminus = GetRMinus[t];
  85.         rplus = GetRPlus[t];
  86.         lastrminus = If [ ListQ[rminus], Last[rminus], rminus ];
  87.         lastrplus  = If [ ListQ[rplus],  Last[rplus],  rplus  ];
  88.         dimsleft = Length[nleft];
  89.         result = SubstituteForT[transq, t, s, Apply[fun, slist]];
  90.         For [ dim = 1, dim <= dimsleft, dim++,
  91.               result = ScaleT [ transq, result, SignalProcessing`ROCinfo[nleft[[dim]], lastrminus, lastrplus]] ];
  92.         result ]
  93.  
  94. (*  multiDInvTransform  *)
  95. multiDInvTransform[e_, s_, t_, op_, transq_, trans_, makeobject_, tdefault_] :=
  96.     Block [    {dim, newop, numdims, result, rminus, roclist,
  97.          rplus, sexpr, timedims, tlist},
  98.         numdims = Length[s];
  99.         timedims = Length[t];
  100.         tlist = If [ TrueQ[ numdims > timedims ],
  101.                  Message[ MultiDInvTransform::notenough ];
  102.                    DummyVariables[ numdims, tdefault],
  103.                  Take[t, numdims] ]; 
  104.         newop = multiDLookup[op, s, tlist];
  105.         If [ transq[e],
  106.              rplus = GetRPlus[e];
  107.              rminus = GetRMinus[e];
  108.              result = TheFunction[e];
  109.              For [ dim = 1, dim <= numdims, dim++,
  110.                roclist = { result, rminus[[dim]], rplus[[dim]] };
  111.                sexpr = makeobject[ roclist, s[[dim]] ];
  112.                result = trans[sexpr, s[[dim]], tlist[[dim]], newop] ],
  113.              result = e;
  114.              For [ dim = 1, dim <= numdims, dim++,
  115.                result = trans[result, s[[dim]], tlist[[dim]], newop] ] ];
  116.         result ]
  117.  
  118. (*  multiDLookup  *)
  119. expandpairs[ x_, nlist_, X_, zlist_, roc_] :=
  120.     Block [ {dim, exprx, exprX, fullrhs, i, org, pattern, rocflag, rules},
  121.         rocflag = ! EmptyQ[roc];
  122.         dim = Length[nlist];
  123.         org = Apply[x,
  124.                 Prepend[ Map[GeneratePattern, Rest[nlist]], 
  125.                      nlist[[1]] ] ];
  126.         rhs = Apply[X, nlist];
  127.         rhs[[1]] = zlist[[1]];
  128.         fullrhs = If [ rocflag, Prepend[roc[[1]], rhs], rhs ];
  129.         rules = { org -> fullrhs };
  130.         lhs = Apply[ X, org ];
  131.         For [ i = 2, i <= dim, i++,
  132.               lhs[[i-1]] = GeneratePattern[ zlist[[i-1]] ];
  133.               lhs[[i]] = nlist[[i]];
  134.               rhs[[i]] = zlist[[i]];
  135.               fullrhs = If [ rocflag, Prepend[roc[[i]], rhs], rhs ];
  136.               AppendTo[ rules, lhs -> fullrhs ] ];
  137.         ToCollection[rules] ]
  138.  
  139. expandone[ x_[nvars___] -> X_[zvars___], nlist_, zlist_ ] :=
  140.     expandpairs[x, {nvars}, X, {zvars}, {}] /;
  141.     SubsetQ[{nvars}, nlist] && SubsetQ[{zvars}, zlist]
  142. expandone[ x_[nvars___] :> X_[zvars___], nlist_, zlist_ ] :=
  143.     expandpairs[x, {nvars}, X, {zvars}, {}] /;
  144.     SubsetQ[{nvars}, nlist] && SubsetQ[{zvars}, zlist]
  145. expandone[ x_[nvars___] -> { X_[zvars___], rm_, rp_ }, nlist_, zlist_ ] :=
  146.     expandpairs[x, {nvars}, X, {zvars}, Transpose[{rm,rp}]] /;
  147.     SubsetQ[{nvars}, nlist] && SubsetQ[{zvars}, zlist]
  148. expandone[ x_[nvars___] :> { X_[zvars___], rm_, rp_ }, nlist_, zlist_ ] :=
  149.     expandpairs[x, {nvars}, X, {zvars}, Transpose[{rm,rp}]] /;
  150.     SubsetQ[{nvars}, nlist] && SubsetQ[{zvars}, zlist]
  151. expandone[ rule_, nlist_, zlist_ ] := rule
  152.  
  153. multiDLookup[op_, nlist_, zlist_] :=
  154.     Block [ {lookupPairs, newop, newpairs},
  155.         newop = op;
  156.         lookupPairs = Replace[TransformLookup, op];
  157.         If [ ! SameQ[lookupPairs, TransformLookup] &&
  158.              ! SameQ[lookupPairs, {}],
  159.              newpairs = Map[expandone[#, nlist, zlist]&, lookupPairs];
  160.              newop = Join[ RemoveOptions[op, {TransformLookup}],
  161.                    { TransformLookup -> newpairs } ] ];
  162.         newop ]
  163.  
  164. (*  multiDTransform  *)
  165. multiDTransform[makeobjectfun_, transform_, transq_, e_, time_, s_, sl_, op_] :=
  166.     Block [    {dialflag, index, newop, numdims, result, slist},
  167.         numdims = Length[time];
  168.         result = e;
  169.         slist = If [ AtomQ[sl], Table[sl, {index, 1, numdims}], sl ];
  170.         If [ Length[slist] < numdims,
  171.              Message[MultiDTransform::notenough];
  172.              slist = DummyVariables[numdims, s] ];
  173.         newop = multiDLookup[op, time, slist];
  174.         For [ index = 1, index <= numdims, index++,
  175.               result = transform [ newop, result, time[[index]],
  176.                        slist[[index]], time, slist ];
  177.               If [ ! TrueQ[transq[result]], Break[] ] ];
  178.         makeobjectfun[result] ]
  179.  
  180. multiDTransform[makeobjectfun_, transform_, transq_, e_, time_, s_, sl_] :=
  181.     Block [    {index, numdims, result, slist},
  182.         numdims = Length[time];
  183.         result = e;
  184.         slist = If [ AtomQ[sl], Table[sl, {index, 1, numdims}], sl ];
  185.         If [ Length[slist] < numdims,
  186.              Message[MultiDTransform::notenough];
  187.              slist = DummyVariables[numdims, s] ];
  188.         For [ index = 1, index <= numdims, index++,
  189.               result = transform [ result, time[[index]],
  190.                        slist[[index]], time, slist ];
  191.               If [ ! TrueQ[transq[result]], Break[] ] ];
  192.         makeobjectfun[result] ]
  193.  
  194.  
  195. (*  E N D     P A C K A G E  *)
  196.  
  197. End[]
  198. EndPackage[]
  199.  
  200.  
  201. (*  E N D I N G     M E S S A G E  *)
  202.  
  203. Print["Routines supporting multidimensional transforms are loaded."]
  204. Null
  205.